package com.central.scheduler.remote.command.alert;

import com.central.scheduler.remote.command.Command;
import com.central.scheduler.remote.command.CommandType;
import com.central.scheduler.remote.utils.JsonSerializer;

import java.io.Serializable;
import java.util.List;

/**
 * @author Tindy
 * @date 2021/10/29
 * @describe
 */
public class AlertSendResponseCommand implements Serializable {

    /**
     * true:All alert are successful,
     * false:As long as one alert fails
     */
    private boolean resStatus;

    private List<AlertSendResponseResult> resResults;

    public boolean getResStatus() {
        return resStatus;
    }

    public void setResStatus(boolean resStatus) {
        this.resStatus = resStatus;
    }

    public List<AlertSendResponseResult> getResResults() {
        return resResults;
    }

    public void setResResults(List<AlertSendResponseResult> resResults) {
        this.resResults = resResults;
    }

    public AlertSendResponseCommand() {

    }

    public AlertSendResponseCommand(boolean resStatus, List<AlertSendResponseResult> resResults) {
        this.resStatus = resStatus;
        this.resResults = resResults;
    }

    /**
     * package response command
     *
     * @param opaque request unique identification
     * @return command
     */
    public Command convert2Command(long opaque) {
        Command command = new Command(opaque);
        command.setType(CommandType.ALERT_SEND_RESPONSE);
        byte[] body = JsonSerializer.serialize(this);
        command.setBody(body);
        return command;
    }
}
